= field_set do
  = f.input :invoiced_at
  = f.referenced_association :responsible, source: {scope: :users}, new: {employed: 1}
  = f.input :description
  = f.association :client, as: :hidden
  = f.association :affair, as: :hidden
  = f.association :nature, as: :hidden
  = f.association :credited_sale, as: :hidden
  = f.input :credit, as: :hidden
  = f.input :currency, as: :hidden
  = f.custom_fields

= field_set Sale.human_attribute_name(:items) do
  .items
    %table
      %thead
        %tr
          %th= SaleItem.human_attribute_name(:variant)
          %th= SaleItem.human_attribute_name(:unit_pretax_amount)
          %th= SaleItem.human_attribute_name(:credited_quantity)
          %th= SaleItem.human_attribute_name(:tax)
          %th= SaleItem.human_attribute_name(:reduction_percentage)
          %th= SaleItem.human_attribute_name(:pretax_amount)
          %th= SaleItem.human_attribute_name(:amount)
          %th= SaleItem.human_attribute_name(:currency)
          %th
      %tbody#items
        = f.simple_fields_for :items, f.object.items do |item|
          = render 'item_fields', f: item
      - precision = Nomen::Currency[f.object.currency].precision
      %tfoot
        %tr.total
          %th
          %th{colspan: 4}= :total.tl
          %td#pta.decimal{data: {use: ".pta", calculate: "sum", calculate_round: precision}}= f.object.pretax_amount
          %td#wta.decimal{data: {use: ".wta", calculate: "sum", calculate_round: precision}}= f.object.amount
          %td= f.object.currency
          %th
